package com.szqhyxj.youxiangju.biz.partnerHome.home.equipmentrepayment;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.szqhyxj.youxiangju.BaseActivity;
import com.szqhyxj.youxiangju.R;
import com.szqhyxj.youxiangju.biz.partnerHome.home.peasonalperformancerepayment.PeasonalPerformanceRepaymentActivity;
import com.szqhyxj.youxiangju.biz.partnerHome.home.teamperformancerepayment.TeamPerformanceRepaymentActivity;
import com.szqhyxj.youxiangju.sys.components.NavigationBar;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by leung on 2018/11/8.
 */

public class EquipmentRepaymentActivity extends BaseActivity implements NavigationBar.NavigationBarListener, EquipmentRepaymentContract.View {

    @BindView(R.id.navigationBar)
    NavigationBar navigationBar;
    @BindView(R.id.teamperformance)
    TextView teamperformance;
    @BindView(R.id.repayment_sumTradeAmt)
    TextView repaymentSumTradeAmt;
    @BindView(R.id.repayment_hundredOfMillionPeoples)
    TextView repaymentHundredOfMillionPeoples;
    @BindView(R.id.repayment_twentyMillionPeoples)
    TextView repaymentTwentyMillionPeoples;
    @BindView(R.id.personalperformance)
    TextView personalperformance;
    @BindView(R.id.merchantSumTradeAmt)
    TextView merchantSumTradeAmt;
    @BindView(R.id.historicalperformance)
    LinearLayout historicalperformance;
    @BindView(R.id.profitRreward)
    TextView profitRreward;
    @BindView(R.id.manageReward)
    TextView manageReward;
    @BindView(R.id.excellentReward)
    TextView excellentReward;
    @BindView(R.id.honourReward)
    TextView honourReward;

    EquipmentRepaymentPresenter presenter;

    public static void start(Activity activity) {
        Intent intent = new Intent();
        intent.setClass(activity, EquipmentRepaymentActivity.class);
        activity.startActivity(intent);

    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_equipment_repayment);
        ButterKnife.bind(this);
        navigationBar.setNavigationBarListener(this);
        presenter = new EquipmentRepaymentPresenter(this);
        presenter.init();
    }

    @OnClick({R.id.teamperformance, R.id.personalperformance, R.id.historicalperformance})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.teamperformance:
                TeamPerformanceRepaymentActivity.start(this);
                break;
            case R.id.personalperformance:
                PeasonalPerformanceRepaymentActivity.start(this);
                break;
            case R.id.historicalperformance:

                break;
        }
    }

    @Override
    public void navigationLeft() {
        finish();
    }

    @Override
    public void navigationRight() {

    }


    @Override
    public void showEquipmentRepaymentInfo(EquipmentRepaymentModel.EquipmentRepaymentEntity equipmentRepaymentEntity) {
        repaymentSumTradeAmt.setText(equipmentRepaymentEntity.getPartnerIndexSubEntity().getSumTradeAmt() + "");
        repaymentHundredOfMillionPeoples.setText(equipmentRepaymentEntity.getPartnerIndexSubEntity().getHundredOfMillionPeoples() + "");
        repaymentTwentyMillionPeoples.setText(equipmentRepaymentEntity.getPartnerIndexSubEntity().getTwentyMillionPeoples() + "");
        merchantSumTradeAmt.setText(equipmentRepaymentEntity.getMerchantSumTradeAmt() + "");
        if (equipmentRepaymentEntity.getRewards().getProfitRreward().equals("0")) {
            profitRreward.setText("暂不满足条件");
        } else {
            profitRreward.setText(equipmentRepaymentEntity.getRewards().getProfitRreward() + "");
        }
        if (equipmentRepaymentEntity.getRewards().getExcellentReward().equals("0")) {
            manageReward.setText("暂不满足条件");
        } else {
            manageReward.setText(equipmentRepaymentEntity.getRewards().getExcellentReward() + "");
        }
        if (equipmentRepaymentEntity.getRewards().getExcellentReward().equals("0")) {
            excellentReward.setText("暂不满足条件");
        } else {
            excellentReward.setText(equipmentRepaymentEntity.getRewards().getExcellentReward() + "");
        }
        if (equipmentRepaymentEntity.getRewards().getHonourReward().equals("0")) {
            honourReward.setText("暂不满足条件");
        }else{
            honourReward.setText(equipmentRepaymentEntity.getRewards().getHonourReward()+"");
        }


    }
}
